package com.shadow.mall.risk.api.impl;


import com.shadow.mall.common.core.JsonResult;
import com.shadow.mall.common.utils.LoggerFormat;
import com.shadow.mall.risk.api.RiskApi;
import com.shadow.mall.risk.domain.dto.CheckOrderRiskDTO;
import com.shadow.mall.risk.domain.request.CheckOrderRiskRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Component;

/**
 *
 * @version 1.0
 */
@Slf4j
@Component
public class RiskApiImpl implements RiskApi {

    @Override
    public JsonResult<CheckOrderRiskDTO> checkOrderRisk(CheckOrderRiskRequest checkOrderRiskRequest) {
        log.info(LoggerFormat.build()
                .remark("checkOrderRisk->request")
                .data("request", checkOrderRiskRequest)
                .finish());
        // 执行风控检查 TODO
        CheckOrderRiskDTO checkOrderRiskDTO = new CheckOrderRiskDTO();
        checkOrderRiskDTO.setResult(true);
        // 默认风控检查通过
        log.info(LoggerFormat.build()
                .remark("checkOrderRisk->response")
                .data("response", checkOrderRiskDTO)
                .finish());
        return JsonResult.buildSuccess(checkOrderRiskDTO);
    }

    @Override
    public JsonResult<String> testDubbo(String param) {
        log.info("remote call -----------------");
        return JsonResult.buildSuccess("success");
    }
}